/*
 * Map.cpp
 *
 *  Created on: Jun 20, 2012
 *      Author: The Almighty Eric
 */

#include "Map.h"

Map::Map()
{
	name = "";
	audio = "";
	grid = lockgrid = false;
	gridx = gridy = 0;
	objects = new std::list<MapObjects>;
	it = objects.begin();
}

void Map::setname(std::string name)
{
	this.name = name;
}

void Map::setaudio(std::string audio)
{
	this.audio = audio;
}

void Map::setgrid(int x, int y)
{
	gridx = x;
	gridy = y;
}

void Map::showgrid(bool g)
{
	grid = g;
}

void Map::locktogrid(bool l)
{
	lockgrid = l;
}

void Map::placeobject(MapObject o)
{
	objects.add(o);
}

void Map::eraseobject(list<MapObject>::iterator it)
{
	objects.erase(it);
}

list<MapObject>::iterator Map::collision(int mousex, mousey, engine e)
{
	list<MapObject>::iterator it;
	SDL_Rect mouse = SDL_Rect();
	mouse.x = mousex;
	mouse.y = mousey;
	mouse.h = 1;
	mouse.w = 1;
	for(it = objects.begin(); it != objects.end(); it++)
	{
		if(e.CollisionCheck(mouse, it->s.CollBox))
			return it;
	}
}
